package com.huitong.oss.dubbo;

import com.huitong.api.oss.exception.UploadException;
import com.huitong.api.oss.remote.RemoteOSSService;
import com.huitong.oss.utils.OSSUtils;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

/**
 * 远程调用文件上传服务服务层
 *
 * @author fromdrowning
 * @date 2024/5/19 下午7:47
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteOSSServiceImpl implements RemoteOSSService {

    /**
     * 文件上传
     *
     * @param fileName 文件名
     * @param file     文件
     * @return 上传云端后文件的访问路径
     * @throws UploadException 文件上传失败抛出此异常
     */
    @Override
    public String uploadFile(String fileName, byte[] file) throws UploadException {
        return OSSUtils.upload(fileName, file);
    }
}
